package com.yunzhong.appointment.essentialinformation.service.impl;

import com.github.pagehelper.PageHelper;
import com.yunzhong.appointment.entity.Bigthing;
import com.yunzhong.appointment.essentialinformation.service.IChronicleOfEventsService;
import com.yunzhong.appointment.mapper.BigthingMapper;
import com.yunzhong.appointment.util.PageData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;

/**
 * @author 王仁海
 * @author ThinkPad
 * @desc 大事记的模型层实现类
 */
@Service
public class ChronicleOfEventsServiceImpl implements IChronicleOfEventsService {
    /**
     * 引入大事记的Mapper接口
     */
    @Autowired
    BigthingMapper bigthingMapper;

    @Override
    public List<Bigthing> queryNotes(PageData pd) {

        pd.setPageData(pd);
        return bigthingMapper.listBigthing(pd);
    }

    @Override
    public Bigthing queryById(String id) {
        return bigthingMapper.selectByPrimaryKey(id);
    }

    @Override
    public int delete(String[] ids) {
        int tiao = 0;
        for (int i = 0; i < ids.length; i++) {
            tiao = bigthingMapper.deleteByPrimaryKey(ids[i]);
        }
        return tiao;
    }

    @Override
    public void save(Bigthing dsj) {
        dsj.setBigthingId(UUID.randomUUID().toString());
        bigthingMapper.insertSelective(dsj);
    }

    @Override
    public int edit(Bigthing dsj) {
        return bigthingMapper.updateByPrimaryKeySelective(dsj);
    }


}
